23/34

# Hadoop Module

These functions are in the `http://xmlns.oracle.com/hadoop/xquery` namespace. The `oxh` prefix is predeclared and the module is automatically imported.

The Hadoop module is described in the following topic:

- Hadoop Functions

## Built-in Functions for Using Hadoop

The following functions are built in to Oracle XQuery for Hadoop:

- `oxh:find`

- `oxh:increment-counter`

- `oxh:println`

- `oxh:println-xml`

- `oxh:property`

### oxh:find

Returns a sequence of file paths that match a pattern.

Signature

    oxh:find($pattern as xs:string?) as xs:string*

Parameters

`$pattern`: The file pattern to search for

See Also:

For the file pattern, the `globStatus` method in the Apache Hadoop API at

`http://hadoop.apache.org/docs/current/api/org/apache/hadoop/fs/FileSystem.html#globStatus(org.apache.hadoop.fs.Path)`

### oxh:increment-counter

Increments a user-defined MapReduce job counter. The default increment is one (1).

Signature

    oxh:increment-counter($groupName as xs:string, $counterName as xs:string, $value as xs:integer

    oxh:increment-counter($groupName as xs:string, $counterName as xs:string

Parameters

`$groupName`: The group of counters that this counter belongs to.

`$counterName`: The name of a user-defined counter

`$value`: The amount to increment the counter

### oxh:println

Prints a line of text to `stdout` of the Oracle XQuery for Hadoop client process. Use this function when developing queries.

Signature

    declare %updating function oxh:println($arg as xs:anyAtomicType?)

Parameters

`$arg`: A value to add to the output. A `cast` operation first converts it to `string`. An empty sequence is handled the same way as an empty string.

Example

This example prints the values of `data.txt` to `stdout`:

    for $i in text:collection("data.txt")
    return oxh:println($i)

### oxh:println-xml

Prints a line of text or XML to `stdout` of the Oracle XQuery for Hadoop client process. Use this function when developing queries and printing nodes of an XML document.

Signature

    declare %updating function oxh:println-xml($arg as item()?)

Parameters

`$arg`: A value to add to the output. The input item is converted into a text as defined by XSLT 2.0 and XQuery 1.0 Serialization specifications. An empty sequence is handled the same way as an empty string.

### oxh:property

Returns the value of a Hadoop configuration property.

Signature

    oxh:property($name as xs:string?) as xs:string?

Parameters

`$name`: The configuration property